package com.rong.iconhero.vo;

import lombok.Data;

/**
 * @author 周厚荣
 * @date 2025/4/21 15:07
 */
@Data
public class ResponseVO<T> {
    private String status;
    private Integer code;
    private String info;
    private T data;

    public static final int SUCCESS_CODE = 200;
    public static final int FAIL_CODE = 500;


    public static  <T> ResponseVO getSuccessResponseVO(T t) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setStatus("success");
        responseVO.setCode(SUCCESS_CODE);
        responseVO.setInfo("请求成功");
        responseVO.setData(t);
        return  responseVO;
    }

    public static <T> ResponseVO getFailResponseVO(Integer code,T t) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(code);
        responseVO.setStatus("error");
        responseVO.setInfo("发生错误");
        responseVO.setData(t);
        return responseVO;
    }

    public static <T> ResponseVO getFailResponseVO(T t) {
        ResponseVO<T> responseVO = new ResponseVO<>();
        responseVO.setCode(FAIL_CODE);
        responseVO.setStatus("error");
        responseVO.setInfo("发生错误");
        responseVO.setData(t);
        return responseVO;
    }
}
